<?php 
/*
 * Category-Functions.php
 * Created By :A Kundu
 * Date: 21/04/2011
 * Function: Ajax Post values From admin-themelist for edit/add/delete categories.
 * Requires : db-config.php
 */


include '../conf/db-config.php';

$action=$_REQUEST['action'];

	if($action=="add")
	{
		$categoryName =  addslashes($_REQUEST['name']);
		$run=mysql_query("INSERT INTO tbl_category_listing(`name`) VALUES('".$categoryName."')");
		if($run)
		{
			echo 1;
		}
		else
		{
			echo 0;
		}
	}
	else if($action=="edit")
	{
		$editId = $_REQUEST['id'];
		$editedName = $_REQUEST['name'];
		
		
		
		$run=mysql_query("UPDATE tbl_category_listing SET `name`='".$editedName."' WHERE `id`=".$editId);
		if($run)
		{
			echo 1;
		}
		else
		{
			echo 0;
		}
	}
	else if($action=="delete")
	{
		$deleteId = $_REQUEST['id'];
		$run = mysql_query("DELETE FROM tbl_category_listing WHERE `id`=".$deleteId);
		if($run)
		{
			echo 1;
		}
		else
		{
			echo 0;
		}
	}